import { createRouter, createWebHistory } from 'vue-router'
import Index from '../views/index.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'index',
      component: Index,
      meta:{title:'简约博客'},
    },
    {
      path: '/details/:titleId',
      name: 'Details',
      component: () => import('../views/DetailsPage.vue'),
      meta:{title:'详情'}
    },
    {
      path: '/creation',
      name: 'Creation',
      component: () => import('../views/Creation.vue'),
      meta:{isAuth:true,title:'创作中心'}
    },
    {
      path: '/message',
      name: 'Message',
      component: () => import('../views/Message.vue'),
      meta:{isAuth:true,title:'消息中心'}
    },
    {
      path: '/user',
      name: 'User',
      component: () => import('../views/UserCenter.vue'),
      meta: {isAuth:true,title: '个人中心'},
      children:[
        {
          path: '/account',
          name: 'UserAccount',
          component: () => import('../components/UserComponents/UserCenterCom.vue'),
          meta: {isAuth:true,title: '账号'},
        },
        {
          path: '/exitLogin',
          name: 'ExitLogin',
          component: () => import('../views/ExitLogin.vue'),
        },]
    },
    {
      path: '/login',
      name: 'Login',
      component: () => import('../views/Login.vue'),
      meta: {title:'登录'}
    },
    
    
  ]
})
//获取原型对象上的push函数
const originalPush = router.push
//修改原型对象中的push方法
router.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}


export default router
